package com.lzh.sms.config;

import com.google.gson.Gson;
import com.lzh.sms.props.AliYunSMSProperty;
import com.lzh.sms.sms.SmsComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhehen.lu
 * @date 2025/8/14 17:01
 */
@Configuration
@ConditionalOnProperty(name = "aliyun.sms.enabled", havingValue = "true")
@EnableConfigurationProperties({ AliYunSMSProperty.class })
public class AliyunSMSComponentConfig {

    @Autowired
    private AliYunSMSProperty aliYunSMSProperty;

    @Bean
    public SmsComponent aliyunSmsComponent(Gson gson) {
        return new SmsComponent(gson, aliYunSMSProperty);
    }

}
